//
//  UIFont.Initialize.swift
//  App_Common_UIKitExtensions
//
//  Created by 蒋晨成 on 2022/2/7.
//

import UICore
import UIKit

public extension UIFont {
    enum FontName: String {
        case pingFangSC = "PingFangSC"
        case sfProDisplay = "SFProDisplay"
        case futura = "Futura"
        case bebasNeue = "BebasNeue"
    }

    static func semiboldOrSystem(_ size: CGFloat, fontName: FontName) -> UIFont {
        UIFont(name: String("\(fontName)-Semibold"), size: size) ?? UIFont.systemFont(ofSize: size)
    }

    static func regularOrSystem(_ size: CGFloat, fontName: FontName) -> UIFont {
        UIFont(name: String("\(fontName)-Regular"), size: size) ?? UIFont.systemFont(ofSize: size)
    }

    static func mediumOrSystem(_ size: CGFloat, fontName: FontName) -> UIFont {
        UIFont(name: String("\(fontName)-Medium"), size: size) ?? UIFont.systemFont(ofSize: size)
    }

    static func thinOrSystem(_ size: CGFloat, fontName: FontName) -> UIFont {
        UIFont(name: String("\(fontName)-Thin"), size: size) ?? UIFont.systemFont(ofSize: size)
    }
}

public extension UIFont {
    static let h1 = UIFont.semiboldOrSystem(27, fontName: .sfProDisplay)
    static let h2 = UIFont.semiboldOrSystem(21, fontName: .sfProDisplay)
    static let h3 = UIFont.semiboldOrSystem(17, fontName: .sfProDisplay)
    static let cust = UIFont.regularOrSystem(17, fontName: .sfProDisplay)
    static let headLine = UIFont.mediumOrSystem(15, fontName: .sfProDisplay)
    static let root = UIFont.regularOrSystem(15, fontName: .sfProDisplay)
    static let subTitle = UIFont.mediumOrSystem(13, fontName: .sfProDisplay)
    static let body = UIFont.regularOrSystem(13, fontName: .sfProDisplay)
    static let link = UIFont.mediumOrSystem(11, fontName: .sfProDisplay)
    static let caption = UIFont.regularOrSystem(11, fontName: .sfProDisplay)
    static let dateCaption = UIFont.regularOrSystem(12, fontName: .pingFangSC)
    static let tag = UIFont.mediumOrSystem(9, fontName: .sfProDisplay)
    static let numberFutura = UIFont.mediumOrSystem(19, fontName: .futura)
}
